<?php
    session_start();
    include("connect.php");
    $username=$_POST['username'];
    $password=$_POST['password'];

    if ($username && $password){
        $ambil=mysql_query("select * from pengguna where username='$username'");
        if(mysql_num_rows($ambil)> 0){
            $asik=mysql_fetch_assoc($ambil);
            if ($password==$asik['password']){
                $_SESSION['username']=$username;
                $_SESSION['id']=$asik['ID'];
                include("kurakura.php");
            }
            else{
                echo("Your Password Incorrect, Please Try Again.");
                include("index.php");
            }
        }
        else {
            echo("You are not authenticate, Please Register now");
            include("index.php");
        }
    }
    else {
        if ($_SESSION['username']){
                include("kurakura.php");
        }
        else{
            echo("There is no Username or Password");
            include("index.php");
        }
    }
?>
